package jh.com.jhappbf.dispatchcar;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.ab.activity.AbActivity;
import com.ab.view.titlebar.AbTitleBar;

import java.util.ArrayList;
import java.util.List;

import androidx.core.content.ContextCompat;
import jh.com.jhappbf.R;

/**
 * @author Administrator
 */
public class DispatchCarSelectTransport extends AbActivity {

    private ListView mList;
    private List<String> mData = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setAbContentView(R.layout.dispatch_car_select_transport);
        AbTitleBar mAbTitleBar = this.getTitleBar();
        mAbTitleBar.setTitleText(R.string.dispatch_car_add_title);
        mAbTitleBar.setLogo(R.drawable.button_selector_back);
        mAbTitleBar.setTitleBarBackgroundColor(ContextCompat.getColor(this, R.color.orange));
        mAbTitleBar.setTitleTextMargin(10, 0, 0, 0);
        mAbTitleBar.setLogoLine(R.mipmap.line);
        initView();
    }

    /**
     * 初始化
     */
    private void initView() {
        mData.add("散装");
        mData.add("袋装");
        mData.add("桶装");

        mList = findViewById(R.id.dispatch_car_select_transport);
        ArrayAdapter<String> adapter = new ArrayAdapter<>(DispatchCarSelectTransport.this,
                android.R.layout.simple_list_item_1, mData);
        mList.setAdapter(adapter);
        mList.setOnItemClickListener((parent, view, position, id) -> {
            Intent i = new Intent();
            String result = mData.get(position);
            i.putExtra("result", result);
            setResult(1, i);
            DispatchCarSelectTransport.this.finish();
        });
    }
}
